package com.nbsaas.boot.quartz.rest.resource;

import com.nbsaas.boot.quartz.api.apis.SchedulingTaskApi;
import com.nbsaas.boot.quartz.data.entity.SchedulingTask;
import com.nbsaas.boot.quartz.api.domain.request.SchedulingTaskRequest;
import com.nbsaas.boot.quartz.api.domain.response.SchedulingTaskResponse;
import com.nbsaas.boot.quartz.api.domain.simple.SchedulingTaskSimple;
import com.nbsaas.boot.quartz.rest.convert.SchedulingTaskSimpleConvert;
import com.nbsaas.boot.quartz.rest.convert.SchedulingTaskEntityConvert;
import com.nbsaas.boot.quartz.rest.convert.SchedulingTaskResponseConvert;
import com.nbsaas.boot.quartz.data.repository.SchedulingTaskRepository;

import java.io.Serializable;

import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;

/**
 * 定时任务-业务接口实现
 */
@Transactional
@Service
public class SchedulingTaskResource extends BaseResource<SchedulingTask, SchedulingTaskResponse, SchedulingTaskSimple, SchedulingTaskRequest> implements SchedulingTaskApi {

    @Resource
    private SchedulingTaskRepository schedulingTaskRepository;

    @Override
    public JpaRepositoryImplementation<SchedulingTask, Serializable> getJpaRepository() {
        return schedulingTaskRepository;
    }

    @Override
    public Function<SchedulingTask, SchedulingTaskSimple> getConvertSimple() {
        return new SchedulingTaskSimpleConvert();
    }

    @Override
    public Function<SchedulingTaskRequest, SchedulingTask> getConvertForm() {
        return new SchedulingTaskEntityConvert();
    }

    @Override
    public Function<SchedulingTask, SchedulingTaskResponse> getConvertResponse() {
        return new SchedulingTaskResponseConvert();
    }


}


